13 scanf("%d", &N
); //cin >> N;
16 scanf("%d %d", &T
, &C
); //cin >> T >> C;
17 vector
< vector
<int> > w
;
18 for (int i
=0; i
<C
; ++i
){
20 scanf("%d", &K
); //cin >> K;
22 for (int j
=0; j
<K
; ++j
){
23 scanf("%d", &row
[j
]);//cin >> row[j];
29 memset(dp
, 0, sizeof dp
);
31 for (int j
=0; j
<w
[0].size(); ++j
){
32 dp
[w
[0][j
]][0] = true; //Primer nivel
35 for (int i
=1; i
<C
; ++i
){
36 for (int t
=0; t
<=T
; ++t
){
37 for (int j
=0; j
<w
[i
].size(); ++j
){
38 if (t
- w
[i
][j
] >= 0){
39 if (dp
[t
-w
[i
][j
]][i
-1]){
49 for (int t
=T
; t
>=0; --t
){
51 printf("%d\n", t
);//cout << t << endl;
58 printf("no solution\n");//cout << "no solution" << endl;